//
//  ViewController.m
//  30302
//
//  Created by student on 16/3/18.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@property (nonatomic,strong)CALayer *layer;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    //30302练习:
    //1 (touchesBegan中)当双击时，在触摸位置新建的一个随机颜色固定大小的CALayer对象的方块
    //2 添加上下左右手势控制这个layer上下左右滑动,比如向右，控制这些新建的CAlayer移动到屏幕最右侧，但不要超出屏幕。
    //3 (touchesBegan中)如果点中某个方块，方块设置阴影颜色(亮一点的颜色)、阴影宽度，之前点选的块取消阴影
    //*4 块之间不能重叠

    

    
    
}



- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    
    UITouch *touch  = touches.anyObject;
    if (touch.tapCount >=2) {
        

        
        CALayer *layer = [CALayer layer];
        CGPoint p = [touch locationInView:self.view];
        layer.cornerRadius = 10;
        layer.masksToBounds = YES;
        layer.frame = CGRectMake(p.x, p.y, 80, 80);
        
 
        layer.cornerRadius = arc4random_uniform(1);
        layer.backgroundColor = [UIColor colorWithRed:arc4random_uniform(255)/255.0 green:arc4random_uniform(255)/255.0 blue:arc4random_uniform(255)/255.0 alpha:1].CGColor;
        layer.borderColor = [UIColor colorWithRed:arc4random_uniform(255)/255.0 green:arc4random_uniform(255)/255.0 blue:arc4random_uniform(255)/255.0 alpha:arc4random_uniform(255)/255.0].CGColor;

        [self.view.layer addSublayer:layer];

   
    }
    
    
    
}

@end
